<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<head>
<title>Market place</title>
</head>
<f:view>
	<body>
		<ui:composition template="/templates/adminTemplate.xhtml">
			<ui:define name="content">
				<f:event listener="#{productController.loadAllTofuProducts}"
					type="preRenderComponent"></f:event>

				<div id="sideBarLeft">
					<p:scrollPanel mode="native" style="font-size:0.9em">
						<h:form prependId="false" id="listForm">
							<p:dataTable id="productListTable" var="product"
								value="#{productModel.list}"
								filteredValue="#{productModel.filteredList}" filterEvent="enter"
								resizableColumns="false" rowKey="#{product.id}"
								paginator="true" paginatorAlwaysVisible="false"
								paginatorPosition="top" rows="10"
								rowsPerPageTemplate="5,7,10,15,20,30,40,50"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
								<p:ajax event="rowSelect" update=":detailForm,:headerForm"
									listener="#{productController.onRowSelect}"></p:ajax>

								<p:column headerText="id" sortBy="#{product.id}">
									<h:outputText value="#{product.id}" />
								</p:column>
								<p:column sortBy="#{product.number}">
									<h:outputText value="#{product.number}" />
								</p:column>
								<p:column sortBy="#{product.chineseName}"
									filterBy="#{product.chineseName}" filterMatchMode="contains">
									<h:graphicImage library="images"
										value="../#{product.icon}16.png"></h:graphicImage>
									<h:outputText value="#{product.chineseName}" />
								</p:column>
								<p:column sortBy="#{product.name}" filterBy="#{product.name}"
									filterMatchMode="contains">
									<h:outputText value="#{product.name}" />
								</p:column>
								<p:column headerText="Price" sortBy="#{product.price}">
									<h:outputText value="#{product.price}" />
								</p:column>
								<p:column headerText="Sp. Price"
									sortBy="#{product.specialPrice}">
									<h:outputText value="#{product.specialPrice}" />
								</p:column>
								<p:column headerText="Unit Price" sortBy="#{product.unitPrice}">
									<h:outputText value="#{product.unitPrice}" />
								</p:column>
								<p:column headerText="inventory" sortBy="#{product.inventory}">
									<h:outputText value="#{product.inventory}" />
								</p:column>
								<p:column sortBy="#{product.type.label}"
									filterBy="#{product.type.label}" filterMatchMode="contains">
									<h:outputText value="#{product.type.label}" />
								</p:column>
								<p:column sortBy="#{product.supplier.name}"
									filterBy="#{product.supplier.name}" filterMatchMode="contains">
									<h:outputText value="#{product.supplier.name}" />
								</p:column>
							</p:dataTable>
						</h:form>
					</p:scrollPanel>
				</div>
				<div id="center">
					<p:scrollPanel mode="native" style="font-size:0.9em">
						<h:form prependId="false" id="detailForm">
							<p:panel header="Empty or restore all tofu products' inventory"
								style="margin:50">
								<h:panelGrid columns="2" style="width:100%">
									<p:commandButton value="Empty Tofu inventory"
										actionListener="#{productController.emptyTofuInventory}"
										update=":listForm"
										style="font-size:1.8em; font-weight:bold;font-style:italic;background-color:red"></p:commandButton>
									<h:panelGrid columns="2" style="float:right">
										<p:commandButton value="Restore Tofu inventory"
											actionListener="#{productController.restoreTofuInventory}"
											update=":listForm"
											style="font-size:1.8em; font-weight:bold;background-color:green"></p:commandButton>
										<h:inputText value="#{productModel.tofuInventory}"
											style="font-size:1.8em; font-weight:bold;width:75px"></h:inputText>
									</h:panelGrid>

								</h:panelGrid>
							</p:panel>
						</h:form>
					</p:scrollPanel>
				</div>

				<h:form id="dialogForm">
					<ui:include src="/components/admin/faq/deleteConfirmDialog.xhtml"></ui:include>
					<ui:include src="/components/admin/faq/choosePictureDialog.xhtml"></ui:include>
				</h:form>
			</ui:define>
		</ui:composition>
	</body>
</f:view>
</html>